package ptij.vocoder.baseModel.open_loop;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.ObjectToken;
import ptolemy.data.BooleanToken;
import ptolemy.data.expr.Parameter;
import ptolemy.data.type.*;

import ptij.vocoder.baseModel.*;

//////////////////////////////////////////////////////////////////////////
//// Getminmax
/**

@author Ivan Jeukens
@version v 0.1 07/08/2003
*/
public class Getminmax extends TypedAtomicActor {

    public Getminmax(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);

        T_op = new TypedIOPort(this, "T_op", true, false);
        T_op.setTypeEquals(BaseType.OBJECT);

        txdtx_ctrl = new TypedIOPort(this, "txdtx_ctrl", true, false);
        txdtx_ctrl.setTypeEquals(BaseType.OBJECT);

        T0_min = new TypedIOPort(this, "T0_min", false, true);
        T0_min.setTypeEquals(BaseType.OBJECT);

        T0_max = new TypedIOPort(this, "T0_max", false, true);
        T0_max.setTypeEquals(BaseType.OBJECT);
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    // Input ports
    public TypedIOPort T_op;
    public TypedIOPort txdtx_ctrl;

    // Output Ports
    public TypedIOPort T0_min;
    public TypedIOPort T0_max;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void fire() throws IllegalActionException {
        ObjectToken obj = (ObjectToken) txdtx_ctrl.get(0);
        Short txdtx = (Short) obj.getValue();
        if((txdtx.shortValue() & Cnst.TX_SP_FLAG) != 0) {
            obj = (ObjectToken) T_op.get(0);
            Short arg1 = (Short) obj.getValue();

            _get_minmax(arg1);

            obj = new ObjectToken(_min);
            T0_min.broadcast(obj);

            obj = new ObjectToken(_max);
            T0_max.broadcast(obj);
        }
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    private void _get_minmax(Short t_op) {
        
        
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

    private Short _min;
    private Short _max;
}
